package com.kingyea.kim.task.controller;

import com.kingyea.kim.base.Result;
import com.kingyea.kim.task.condition.TaskCondition;
import com.kingyea.kim.task.service.TaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lgy
 * @version v1.0.0
 * @description
 * @date Created in 2018/8/20 0020 16:26
 */
//@CrossOrigin
@RestController
@RequestMapping("/task")
public class TaskController {

    private final static Logger logger = LoggerFactory.getLogger(TaskController.class);

    @Autowired
    private TaskService taskService;

    /**
     *
     * 通过姓名或者标题获取对象
     */
    @RequestMapping(method = RequestMethod.POST, value = "/selectByCondition")
    @ResponseBody
    public Result selectByCondition(@RequestBody TaskCondition condition) {

        return taskService.selectByCondition(condition);
    }

    /**
     *
     * 待办总条数
     */
    @RequestMapping(method = RequestMethod.POST, value = "/count")
    @ResponseBody
    public Integer selectCount() {
        return taskService.selectCount();
    }

    /**
     *
     * 根据id查询对象
     */
    @RequestMapping(method = RequestMethod.POST, value = "/detail/{id}")
    public Result selectById(Integer id) {
        return taskService.selectById(id);
    }
//    /**
//     *
//     * 添加待办
//     */
//    @RequestMapping(method = RequestMethod.POST, value = "add")
//    @ResponseBody
//    public Object addTask(@RequestBody Task task) {
//        return taskService.save(task);
//    }
//0
//    /**
//     *
//     * 修改待办状态
//     */
//    @RequestMapping(method = RequestMethod.POST, value = "/update")
//    @ResponseBody
//    public Object updateTask(@RequestBody TaskCondition condition) {
//        return taskService.update(condition);
//    }
}

